<div id="content">
#{if flash.success}
    <p class="success">${flash.success}</p>
 #{/if}
<table style="width:100%;"><tr>
<td><h2>&{'manageusertype.title'}</h2></td>
<td style="text-align:right">

	<a id="addusertype" href="#">&{'manageusertype.add'}</a>
	
	</td>
</tr></table>


<table class="tableau">
<tr>
  <th>&{'table.requesttype.id'}</th>
  <th>&{'table.requesttype.describe'}</th>
  <th></th>
</tr>


#{list items:userType, as:'user'}
<tr class="${user_parity}">
  <td>${user.getId()}</td>
  <td>${user.getDescription()}</td>
  <td align="center" >
  	<a href="#" onclick="update(${user.getId()})" ><img src="@{'public/images/edit.png'}" width="25" height="25"/></a>
  	<a href="#" onclick="deleteType(${user.getId()})"><img src="@{'public/images/trash.png'}" width="25" height="25"/></a>
  </td>
  
  
</tr>
#{/list}
</table>
</div>
<script>
	$(function() {
		
		$("#addusertype").button().click(function() {
			// Define Create Action
			var createAction = #{jsAction @ManageUserType.edit() /}

			// Call Create Action
			$.post(createAction(), function(data) {
				// Prepend Results to the List
				
				$('#content').replaceWith(data);
			});
		});
	});
</script>
<script>
//suppression d'un userType
function deleteType(id) {
	var createAction = #{jsAction @ManageUserType.deleteUserType(':userId') /}
	// Call Create Action
	$.post(createAction({userId:id}), function(data) {
		// Prepend Results to the List
		$('#content').replaceWith(data);
	});
}

//mise a jour d'un requestType
function update(id) {
	var createAction = #{jsAction @ManageUserType.edit(':userId') /}
	//Call Create Action
	$.post(createAction({userId:id}), function(data) {
		// Prepend Results to the List
		$('#content').replaceWith(data);
	});
	}
</script>